package com.cdream.basic.algorithm.leetcode.array;

import java.util.Arrays;

/**
 * @author cdream
 * @date 8/23/21
 */
public class Question1646 {
    public int getMaximumGenerated(int n) {
        if(n==0){
            return 0;
        }
        if(n==1){
            return 1;
        }
        int[] res = new int[n+1];
        res[1] = 1;
        int i = 1;
        while(2 * i <=n){
            res[2 * i] = res[i];
            if(2*i +1 <=n){
                res[2 * i +1] = res[i] + res[i + 1];
            }
            i++;
        }
        return Arrays.stream(res).min().getAsInt();
    }
}
